 
import { PositionHelper } from 'utils/position/PositionHelper';
import { getMock } from './mock'

// 伪造 creep 的默认值
export class RoomPositionMock {
   constructor(x?:number,y?:number,RoomName?:string)
   {
      this.x = x as number;
      this.y= y as number;
      this.roomName= RoomName as string;
   }
    roomName: string="W3N1";
    /**
     * X position in the room.
     */
    x: number=1;
    /**
     * Y position in the room.
     */
    y: number = 1;
    public NeighborRoomName(offsetx: number,offsety:number): string
    {
       const worldpos = this.WorldPosition();
       worldpos.x = Math.floor( worldpos.x/50)+ offsetx;
       worldpos.y = Math.floor( worldpos.y/50)+offsety ;
       let resstring='';
       if(worldpos.x<0)
       {
            resstring+='W'+(-worldpos.x-1);
       }
       else
       {
            resstring+='E'+worldpos.x;
       }
       if(worldpos.y<0)
       {
            resstring+='N'+(-worldpos.y-1);
       }
       else
       {
            resstring+='S'+worldpos.y;
       }

       return resstring;
    }
    public WorldPosition(): { [key: string]: number }
    {
        return PositionHelper.ToWorld(this);
       
    }
    public distance(p:IRoomPosition):number
    {
        return PositionHelper.Distance(this,p)
    }
}

/**
 * 伪造一个 creep
 * @param props 该 creep 的属性
 */
export const getMockRoomPosition= getMock<RoomPosition >(RoomPositionMock)
